World happiness project - Data Analysis

Ofir Haim, Veronica Iovchik

24 June, 2021

Background

Our data set comes from Gallup World Poll (From Kaggle).This data frame has an evaluation of happiness around different countries in the world, considering some aspects that effect our life and determine the level of our well-being.


Our goals in this report are:

  1. We will tidy up the data and present it.
  2. We will analyze and visualize the information, using the previous models which we have acquired throughout this semester. 3.Finally, we will explain our findings and share our conclusions.

    Markdown Monster icon

    The models we chose to apply are:

      1. Multiple liner regression
      2. one sided hypothesis T-test

    The results are based on answers to the main life evaluation questions asked in the poll. This dataset comes from Kaggle website.The happiness score based on cantril ladder. These questions ask respondents to think of a ladder with the best possible life for them being a 10, and worst possible life being a 0. The respondents rate their own current lives based on that scale, the data is gathered by countries and the region is specified too. The columns following the happiness score estimate the extent to which each of six factors economic production, social support, life expectancy, freedom, absence of corruption, and generosity, influences happiness among the respondents.

Data Import And Tidying

The dataset imported as a CSV file- a convenient format to work with.The attached libraries used us for analyis the dataset by our chosen models.

suppressWarnings(suppressMessages(library(tidyverse)))
suppressWarnings(suppressMessages(library(ggplot2)))
suppressWarnings(suppressMessages(library(dplyr)))
suppressWarnings(suppressMessages(library(rworldmap)))
suppressWarnings(suppressMessages(library(ggmap)))
suppressWarnings(suppressMessages(library(ggcorrplot)))
suppressWarnings(suppressMessages(library(ggpubr)))
suppressWarnings(suppressMessages(library(plotly)))
suppressWarnings(suppressMessages(library(gapminder)))
suppressWarnings(suppressMessages(library(forcats)))
suppressWarnings(suppressMessages(library(magrittr)))
World_happiness <- read.csv("world-happiness-report-2021 (1).csv")
library(reactable)
reactable(World_happiness)
str(World_happiness)
## 'data.frame':    149 obs. of  20 variables:
##  $ ï..Country.name                           : chr  "Finland" "Denmark" "Switzerland" "Iceland" ...
##  $ Regional.indicator                        : chr  "Western Europe" "Western Europe" "Western Europe" "Western Europe" ...
##  $ Ladder.score                              : num  7.84 7.62 7.57 7.55 7.46 ...
##  $ Standard.error.of.ladder.score            : num  0.032 0.035 0.036 0.059 0.027 0.035 0.036 0.037 0.04 0.036 ...
##  $ upperwhisker                              : num  7.9 7.69 7.64 7.67 7.52 ...
##  $ lowerwhisker                              : num  7.78 7.55 7.5 7.44 7.41 ...
##  $ Logged.GDP.per.capita                     : num  10.8 10.9 11.1 10.9 10.9 ...
##  $ Social.support                            : num  0.954 0.954 0.942 0.983 0.942 0.954 0.934 0.908 0.948 0.934 ...
##  $ Healthy.life.expectancy                   : num  72 72.7 74.4 73 72.4 73.3 72.7 72.6 73.4 73.3 ...
##  $ Freedom.to.make.life.choices              : num  0.949 0.946 0.919 0.955 0.913 0.96 0.945 0.907 0.929 0.908 ...
##  $ Generosity                                : num  -0.098 0.03 0.025 0.16 0.175 0.093 0.086 -0.034 0.134 0.042 ...
##  $ Perceptions.of.corruption                 : num  0.186 0.179 0.292 0.673 0.338 0.27 0.237 0.386 0.242 0.481 ...
##  $ Ladder.score.in.Dystopia                  : num  2.43 2.43 2.43 2.43 2.43 2.43 2.43 2.43 2.43 2.43 ...
##  $ Explained.by..Log.GDP.per.capita          : num  1.45 1.5 1.57 1.48 1.5 ...
##  $ Explained.by..Social.support              : num  1.11 1.11 1.08 1.17 1.08 ...
##  $ Explained.by..Healthy.life.expectancy     : num  0.741 0.763 0.816 0.772 0.753 0.782 0.763 0.76 0.785 0.782 ...
##  $ Explained.by..Freedom.to.make.life.choices: num  0.691 0.686 0.653 0.698 0.647 0.703 0.685 0.639 0.665 0.64 ...
##  $ Explained.by..Generosity                  : num  0.124 0.208 0.204 0.293 0.302 0.249 0.244 0.166 0.276 0.215 ...
##  $ Explained.by..Perceptions.of.corruption   : num  0.481 0.485 0.413 0.17 0.384 0.427 0.448 0.353 0.445 0.292 ...
##  $ Dystopia...residual                       : num  3.25 2.87 2.84 2.97 2.8 ...

Displays the dimensions of the Data set

dim(World_happiness)
## [1] 149  20

Provide summaries of the data set with few descriptive statistics

summary(World_happiness) 
##  ï..Country.name    Regional.indicator  Ladder.score  
##  Length:149         Length:149         Min.   :2.523  
##  Class :character   Class :character   1st Qu.:4.852  
##  Mode  :character   Mode  :character   Median :5.534  
##                                        Mean   :5.533  
##                                        3rd Qu.:6.255  
##                                        Max.   :7.842  
##  Standard.error.of.ladder.score  upperwhisker    lowerwhisker  
##  Min.   :0.02600                Min.   :2.596   Min.   :2.449  
##  1st Qu.:0.04300                1st Qu.:4.991   1st Qu.:4.706  
##  Median :0.05400                Median :5.625   Median :5.413  
##  Mean   :0.05875                Mean   :5.648   Mean   :5.418  
##  3rd Qu.:0.07000                3rd Qu.:6.344   3rd Qu.:6.128  
##  Max.   :0.17300                Max.   :7.904   Max.   :7.780  
##  Logged.GDP.per.capita Social.support   Healthy.life.expectancy
##  Min.   : 6.635        Min.   :0.4630   Min.   :48.48          
##  1st Qu.: 8.541        1st Qu.:0.7500   1st Qu.:59.80          
##  Median : 9.569        Median :0.8320   Median :66.60          
##  Mean   : 9.432        Mean   :0.8147   Mean   :64.99          
##  3rd Qu.:10.421        3rd Qu.:0.9050   3rd Qu.:69.60          
##  Max.   :11.647        Max.   :0.9830   Max.   :76.95          
##  Freedom.to.make.life.choices   Generosity       Perceptions.of.corruption
##  Min.   :0.3820               Min.   :-0.28800   Min.   :0.0820           
##  1st Qu.:0.7180               1st Qu.:-0.12600   1st Qu.:0.6670           
##  Median :0.8040               Median :-0.03600   Median :0.7810           
##  Mean   :0.7916               Mean   :-0.01513   Mean   :0.7274           
##  3rd Qu.:0.8770               3rd Qu.: 0.07900   3rd Qu.:0.8450           
##  Max.   :0.9700               Max.   : 0.54200   Max.   :0.9390           
##  Ladder.score.in.Dystopia Explained.by..Log.GDP.per.capita
##  Min.   :2.43             Min.   :0.0000                  
##  1st Qu.:2.43             1st Qu.:0.6660                  
##  Median :2.43             Median :1.0250                  
##  Mean   :2.43             Mean   :0.9772                  
##  3rd Qu.:2.43             3rd Qu.:1.3230                  
##  Max.   :2.43             Max.   :1.7510                  
##  Explained.by..Social.support Explained.by..Healthy.life.expectancy
##  Min.   :0.0000               Min.   :0.0000                       
##  1st Qu.:0.6470               1st Qu.:0.3570                       
##  Median :0.8320               Median :0.5710                       
##  Mean   :0.7933               Mean   :0.5202                       
##  3rd Qu.:0.9960               3rd Qu.:0.6650                       
##  Max.   :1.1720               Max.   :0.8970                       
##  Explained.by..Freedom.to.make.life.choices Explained.by..Generosity
##  Min.   :0.0000                             Min.   :0.000           
##  1st Qu.:0.4090                             1st Qu.:0.105           
##  Median :0.5140                             Median :0.164           
##  Mean   :0.4987                             Mean   :0.178           
##  3rd Qu.:0.6030                             3rd Qu.:0.239           
##  Max.   :0.7160                             Max.   :0.541           
##  Explained.by..Perceptions.of.corruption Dystopia...residual
##  Min.   :0.0000                          Min.   :0.648      
##  1st Qu.:0.0600                          1st Qu.:2.138      
##  Median :0.1010                          Median :2.509      
##  Mean   :0.1351                          Mean   :2.430      
##  3rd Qu.:0.1740                          3rd Qu.:2.794      
##  Max.   :0.5470                          Max.   :3.482

Densities plot of each of the factor that represents an effective way to understand the distribution of each independence variable

density_social_support <- density(World_happiness$Social.support)         
density_Healthy.life.expectancy <- density(World_happiness$Healthy.life.expectancy)                     
density_Freedom.to.make.life.choices <- density(World_happiness$Freedom.to.make.life.choices)                     
density_Generosity <- density(World_happiness$Generosity)                     
density_Perceptions.of.corruption <- density(World_happiness$Perceptions.of.corruption)                     

suppressWarnings(suppressMessages(attach(mtcars)))
par(mfrow=c(3,2))
suppressWarnings(suppressMessages(plot(density_social_support, main="Density of Social support", col="purple")) +polygon(density_social_support, col="orange"))
## integer(0)
suppressWarnings(suppressMessages(plot(density_Healthy.life.expectancy, main="Density of Freedom.to.make.life.choices")) +polygon(density_Healthy.life.expectancy, col="green"))
## integer(0)
suppressWarnings(suppressMessages(plot(density_Freedom.to.make.life.choices, main="Density of Freedom.to.make.life.choices")) +polygon(density_Freedom.to.make.life.choices, col="yellow"))
## integer(0)
suppressWarnings(suppressMessages(plot(density_Generosity, main="Density of Freedom.to.make.life.choices")) +polygon(density_Generosity, col="purple"))
## integer(0)
suppressWarnings(suppressMessages(plot(density_Perceptions.of.corruption, main="Density of Perceptions.of.corruption")) +polygon(density_Perceptions.of.corruption, col="blue"))
## integer(0)

Our conclusions:

This assignment taught us a lot about the usage of R and implementations of statistical models.

The analysis showed that happiness, as subjective as it is, when translated into quantitative variables,it showed to be complex and dependent on a variety of factors.

As we observed, there is a link between wealth and happiness, with the latter being greater when the former is.

After we analyzed the factors that affected our ladder score, we identified that there is liner fit between them. These factors revealed that the data has linear correlation between factors , and our test hypothesis that higher GDP per Capita effects our happiness is true. Although not all the assumptions of Multiple regression were accepted, we observed the correlations of all the happiness factors from 149 countries on the happiness Score.we found out through Partial F-test that the Full model is significant better that the Partial Model (without Freedom to make life choices)

From our goals we aimed to achieve, we truly believe that accomplished them, and we improved our skills in R, and how to implement Statistic model on data set.

Markdown Monster icon

As for our perspective, we see how this data captures the individuals feeling about their happiness as quality of life on the globe. However we do acknowledge that happiness is subjective, so you may live in an area where the score is lower, but you might fell happier and for you the half glass is full.

Finally, if you had the chance to live in one of the world’s happiest countries, would you consider it?

Thank you for your time